package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizuser"
	"time"
)

type HzUserLoginLogs struct {
	ent.Schema
}

// Fields of the MallUserLoginLogs.
func (HzUserLoginLogs) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("user_id").Comment("用户id"),
		field.Int64("login_type").Default(bizuser.LoginType).Comment("类型"),
		field.Int64("device_type").Comment("设备类型， 1、ios,2、android"),
		field.String("equipment_id").Optional().Comment("设备id"),
		field.String("ip_address").Optional().Comment("ip"),
		field.Int64("login_time").Immutable().Default(0).Comment("登录时间"),
		field.Int64("created_at").Immutable().Default(0).Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}

func (HzUserLoginLogs) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("ip_address"),
		index.Fields("equipment_id"),
	}
}

func (HzUserLoginLogs) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("用户登录日志表"),
	}
}
